<?php ob_start();?>
<?php
	$root = $_SERVER['DOCUMENT_ROOT'];
 	include($root.'/standart/dateHeader.php');
 	include($root.'/standart/dbconnect.php');
 	$db = connect();

 	session_start();
//$usrId = $_GET["user_id"];
$orderId = $_GET["order_id"];
$stmt ="SELECT ORDER_ID, MENU.PRODUCT_NAME, MENU.UNIT,ORDER_ITEMS.PRICE,
(ORDER_ITEMS.PRICE*ORDER_ITEMS.QUANTITY) AS TUTAR,ORDER_ITEMS.QUANTITY,ADDRESS.ADDRESS_1, ORDERS.ORDER_DATE, ORDERS.CANCEL
		FROM ORDER_ITEMS
		LEFT OUTER JOIN ORDERS ON 
		ORDERS.ID=ORDER_ITEMS.ORDER_ID 
		LEFT OUTER JOIN MENU ON 
		ORDER_ITEMS.MENU_ID=MENU.ID
        LEFT OUTER JOIN ADDRESS ON
	ORDERS.SHIPPING_ADDRESS=ADDRESS.ID
        where CANCEL = 0 AND ORDER_ITEMS.ORDER_ID = '$orderId'
        ORDER BY ORDERS.ORDER_DATE DESC";
$res = $db->query($stmt) or die($stmt."<br/><br/>".mysql_error());
	?>
<table class="table table-striped table-bordered table-hover" id="dataTables-example_2">
		<thead>
        	<tr>
        		<th style="display: none;">Sipariş No</th>
                <th>Ürün İsmi</th>				
                <th>Birim Fiyatı</th>
                <th>Sipariş Miktarı</th>
				<th>Birim</th>
                <th>Tutar</th>
                <th>Gönderim Adresi</th>
                <th>Sipariş Tarihi</th>
                <th style="display:none;d">İptal Durumu</th>
            </tr>
		</thead>
        <tbody>
        <?php $odd = true; ?>
        <?php $total = 0.00 ?>
       	<?php while($row = $res->fetch_assoc()){?>
        	<tr class="<?php echo $odd ? "odd" : "even";?> " style="cursor: pointer;">
        		<td style="display: none;"><?php echo $row["ORDER_ID"];?></td>
	            <td><?php echo $row["PRODUCT_NAME"];?></td>
                <td style="text-align: right;"><?php echo $row["PRICE"];  ECHO ' TL';?></td>
                <td style="text-align: right;"><?php echo $row["QUANTITY"];?></td>
                <td><?php echo $row["UNIT"];?></td>
                <td style="text-align: right;"><?php echo number_format($row["TUTAR"], 2); ECHO ' TL';?></td>
                <td><?php echo $row["ADDRESS_1"];?></td>
                <td><?php echo date("d/m/Y H:i",strtotime($row["ORDER_DATE"]));?></td>
                <td style="display:none;"><?php echo $row["CANCEL"];?></td>
                
			</tr>
			<?php $total += $row["TUTAR"] ?>
		<?php }?>
		<?php if(isset($_GET['report'])){?>
			
		<!-- 
	<tfoot>
		<tr>
			<td style="display: none;"></td>
			<td style="display: none;"></td>
			<td style="display: none;"></td>
			<th colspan="4" style="text-align: right">Toplam:</th>
			<th style="text-align: right;"><?php echo number_format($total,2); ECHO ' TL'?></th>
			<td></td>
			<td></td>
		</tr>
	</tfoot>
	-->
		<?php }?>
		</tbody>
     </table>
	<?php 
$res->close();
disconnect($db);
?>
<?php ob_end_flush(); ?>